<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\Shopclickconfig;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class ShopclickconfigController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Shopclickconfig(), function (Grid $grid) {
            $grid->model()->with('user')->orderByDesc('id');


            $grid->column('id')->sortable();
            $grid->column('user.tiktokno',trans('user.fields.tiktokno'))->display(function ($var){
                return $this->user_id."({$var})";
            });
            $grid->column('statr_time');
            $grid->column('taskhour');

            $grid->column('click');
            $grid->column('finish_click');
            $grid->column('created_at');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('user_id',trans('user.fields.tiktokno'))->select(\App\Models\User::getUsers());
            });

            $grid->disableRowSelector();
            $grid->showQuickEditButton();
            $grid->disableViewButton();


        });
    }


    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Shopclickconfig(), function (Form $form) {

            $form->select('user_id')->options(\App\Models\User::getUsers())->required();
            $form->datetime('statr_time')->required();
            $form->number('taskhour')->default(1440)->min(11)->required();
            $form->text('click')->required();
        });
    }


}
